package apigateway.serviceRegister;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 小泽玛丽罗 on 2017/3/1.
 */
public class ServiceNode implements Serializable {

    private static final long serialVersionUID=-740478848062404L;
    String ip;
    int port;
    List<Dependecy> dependencies=new ArrayList<>();
    String type;
    String registePath;
    String location;
    String name;
    String serviceCategory;
    int weight;

    public ServiceNode(){

    }
    public ServiceNode(String ip, int port, String serviceType, String registePath,
                       String location, String name, String serviceCategory,int weight) {
        this.ip = ip;
        this.port = port;
        this.type=serviceType;
        this.registePath=registePath;
        this.location=location;
        this.name=name;
        this.serviceCategory=serviceCategory;
        this.weight=weight;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public List<Dependecy> getDependencies() {
        return dependencies;
    }

    public void setDependencies(List<Dependecy> dependencies) {
        this.dependencies = dependencies;
    }

    public String getServiceCategory() {
        return serviceCategory;
    }

    public void setServiceCategory(String serviceCategory) {
        this.serviceCategory = serviceCategory;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRegistePath() {
        return registePath;
    }

    public void setRegistePath(String registePath) {
        this.registePath = registePath;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getServiceUrl(){
        return ip+":"+port;
    }

    @Override
    public String toString() {
        return "ServiceNode{" +
                "ip='" + ip + '\'' +
                ", port=" + port +
                ", type='" + type + '\'' +
                ", registePath='" + registePath + '\'' +
                '}';
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public boolean isAtomService(){
        if(this.type.equals("atom"))
            return true;
        else
            return false;
    }
}
